use crate::abstractions::portable_fuse::fuse;
use crate::abstractions::task::TaskAbstraction;
use crate::abstractions::portable_task::TaskPortableAbs;
use crate::protocol::type_schema::TypeSchema;
use crate::abstractions::data::Data;
use std::sync::Arc;

fn equivalent_operation(input: Vec<i64>) -> Vec<i64> {
    let mut result = Vec::new();
    for each in input {
        result.push((each + 1) * 2);
    }
    result
}

pub fn test_direct() {
    let task1 = TaskAbstraction::FromService(("http+--127.0.0.1+8080".to_string(), "list_add_1".to_string()));
    let task2 = TaskAbstraction::FromService(("http+--127.0.0.1+8080".to_string(), "int_mul_2".to_string()));
    let task1abs = TaskPortableAbs::from_taskabs(Arc::new(task1)).unwrap();
    let task2abs = TaskPortableAbs::from_taskabs(Arc::new(task2)).unwrap();
    let fused = fuse(&task1abs, &task2abs, false).unwrap();
    let input = Data::DataList(vec![Data::DataInt(1), Data::DataInt(2), Data::DataInt(3)]);
    let output = fused.sendfun()(input, 0).unwrap();
    let expected = Data::DataList(equivalent_operation(vec![1, 2, 3]).iter().map(|x| 
        Data::DataInt(*x)).collect()
    );
    println!("output: {:?}", output);
    println!("expected: {:?}", expected);
}
